//
//  RepairServiceEvaluationView.swift
//  PropertyCommunity
//
//  Created by benwang on 2021/6/29.
//

import UIKit

extension PTSheetHandle {
  /// 报修评价
  func sheet(repairEvaluation: RepairInformationModel?, handle: @escaping Handle) {
    let sheet = R.nib.repairServiceEvaluationView(owner: nil)!
    sheet.model = repairEvaluation
    self.sheet(PTSheetHandle.Content(sheet: sheet), handle: handle)
  }
}


class RepairServiceEvaluationView: UIView {

  private var completeHandle: PTSheetHandle.Handle?

  var model: RepairInformationModel?

    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

  @IBAction func tappedClose(_ sender: Any) {
    completeHandle?(.cancel)
  }
}

extension RepairServiceEvaluationView: PTSheetConfigurable {

  var handle: PTSheetHandle.Handle? {
      get {
          return completeHandle
      }
      set {
          completeHandle = newValue
      }
  }

  func shouldUpdateLayoutConstraints() {

    self.snp.remakeConstraints { (make) in
      make.centerX.equalToSuperview()
      make.centerY.equalToSuperview().offset(-25)
      make.width.lessThanOrEqualTo(320)
      make.height.greaterThanOrEqualTo(200)
      make.left.equalToSuperview().offset(47).priority(.high)
      make.right.equalToSuperview().offset(-47).priority(.high)
    }
  }
}
